#ifndef _TCPSERVER_H
#define _TCPSERVER_H
#include "TcpConnection.hpp"
#include "Acceptor.hpp"
#include "EventLoop.hpp"

class TcpServer{
public:
    TcpServer(uint16_t port,string ip="0.0.0.0"):_acp(port,ip),_evLoop(_acp){}
    void setAllCallBack(TcpConnectionCall && onConnect
                        ,TcpConnectionCall && onMessage
                        ,TcpConnectionCall && onClose){
        _evLoop.setAllCallBack(std::move(onConnect),std::move(onMessage),std::move(onClose));
    }
    ~TcpServer() = default;
    void start(){
        _acp.ready();
        _evLoop.loop();
    }
    void stop(){
        _evLoop.unloop();
    }
private:
    Acceptor _acp;
    EventLoop _evLoop;
};





#endif
